﻿using SqlSugar;

namespace SqlSugarCore.Dal.BaseRealize
{
    public enum SqlWithEnum
    {
        HoldLock,
        NoLock,
        Null,
        PagLock,
        ReadCommitted,
        RowLock,
        TabLockX,
        UpdLock
    }

    /// <summary>
    /// 查询相关基本实现
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public partial class BaseDal<T> where T : class, new()
    {

        /// <summary>
        /// 获取查询对象
        /// </summary>
        /// <returns></returns>
        public ISugarQueryable<T> Queryable()
        {
            var queryable = this._sqlSugarClient.Queryable<T>();
            return queryable;
        }

        /// <summary>
        /// 获取查询对象并指定数据库锁类型
        /// </summary>
        /// <param name="sqlWith"></param>
        /// <returns></returns>
        public ISugarQueryable<T> Queryable(SqlWithEnum sqlWith)
        {
            var queryable = this._sqlSugarClient.Queryable<T>().With(sqlWith.ToString());
            return queryable;
        }
    }
}
